//
//  Emoticon.swift
//  表情键盘
//
//  Created by 叶子韬韬 on 2017/5/10.
//  Copyright © 2017年 叶子韬韬. All rights reserved.
//

import UIKit

class Emoticon: NSObject {

    // MARK:- #注释> 定义属性
    var code:String?{
        didSet{
            guard let code = code else {
                return
            }
            
            //创建扫描器
            let scanner = Scanner(string: code)
            
            var value :UInt32 = 0
            scanner.scanHexInt32(&value)
            
            let c = Character(UnicodeScalar(value)!)
            
            emojiCode = String(c)
            
            
            
            
        }
    }       //emoj的code
    var png:String?{
        didSet{
            guard let png = png else {
                return
            }
            
            pngPath = Bundle.main.bundlePath + "/Emoticons.bundle/" + png
            
        }
    }         //普通表情对应
    var chs:String?
    
    //数据处理
    var pngPath:String?
    
    var emojiCode:String?
    
    var isRemove : Bool = false
    
    var isEmpty : Bool = false
    
    init(dict:[String:String]) {
        super.init()
        setValuesForKeys(dict)
    }
    
    init(isRemove:Bool) {
        super.init()
        self.isRemove = isRemove
    }
    init(isEmpty:Bool) {
        super.init()
        self.isEmpty = isEmpty
    }
    override func setValue(_ value: Any?, forUndefinedKey key: String) {
        
    }
    
    override var description: String{
        
        return dictionaryWithValues(forKeys: ["code","png","chs","pngPath","emojiCode"]).description
    }
}
